# Calculate readability correlations using merged essays; Table S4

library(tidyverse)

merged_read_df <- read.csv("merged_readability.csv")

merged_read_df <- merged_read_df %>%
  filter(FAMILY_INCOME > 10000)

merged_rhi_1 <- lm(FAMILY_INCOME ~ Flesch, data = merged_read_df)
merged_rhi_2 <- lm(FAMILY_INCOME ~ Flesch.Kincaid, data = merged_read_df)
merged_rhi_3 <- lm(FAMILY_INCOME ~ Dale.Chall, data = merged_read_df)
merged_rhi_4 <- lm(FAMILY_INCOME ~ FOG, data = merged_read_df)
merged_rhi_5 <- lm(FAMILY_INCOME ~ SMOG, data = merged_read_df)

summary(merged_rhi_1)$adj.r.squared
summary(merged_rhi_2)$adj.r.squared
summary(merged_rhi_3)$adj.r.squared
summary(merged_rhi_4)$adj.r.squared
summary(merged_rhi_5)$adj.r.squared

merged_sat_1 <- lm(RSAT_TOTAL_SCORE ~ Flesch, data = merged_read_df)
merged_sat_2 <- lm(RSAT_TOTAL_SCORE ~ Flesch.Kincaid, data = merged_read_df)
merged_sat_3 <- lm(RSAT_TOTAL_SCORE ~ Dale.Chall, data = merged_read_df)
merged_sat_4 <- lm(RSAT_TOTAL_SCORE ~ FOG, data = merged_read_df)
merged_sat_5 <- lm(RSAT_TOTAL_SCORE ~ SMOG, data = merged_read_df)

summary(merged_sat_1)$adj.r.squared
summary(merged_sat_2)$adj.r.squared
summary(merged_sat_3)$adj.r.squared
summary(merged_sat_4)$adj.r.squared
summary(merged_sat_5)$adj.r.squared
